import http from './http'

/**
 * 用户登录
 * user: 用户信息
 * */
export async function login (user) {
  const res = await http.post('/user/login', user)
  if (res.status === 200) {
    http.setItem('Authorization', res.data.token)
    return res.data
  }
}

/**
 * 用户注册
 * user: 用户信息
 * */
export async function register(user) {
  const res = await http.post('/user/register', user)
  if (res.status === 200) {
    return res.data
  }
}

/**
 * 用户获取短信验证码
 * user: 用户信息
 * */
export async function sms(user) {
  const res = await http.post('/user/sms', user)
  if (res.status === 200) {
    return res.data
  }
}

/**
 * 忘记（找回）密码
 * user: 用户信息
 * */
export async function forgetPwd(user) {
  const res = await http.post('/user/forgetPwd', user)
  if (res.status === 200) {
    return res.data
  }
}
